package com.wzh.ojbackendjudgeservice.codesandbox.impl;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.wzh.ojModel.model.dto.judge.ExecuteCodeRequest;
import com.wzh.ojModel.model.vo.ExecuteCodeResponse;
import com.wzh.ojbackendjudgeservice.codesandbox.CodeSandbox;


/**
 * @author wzh
 * 远程沙箱
 */
public class RemoteCodeSandbox implements CodeSandbox {
    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {
        String jsonStr = JSONUtil.toJsonStr(executeCodeRequest);
        String url="localhost:8105/executeCode";
        String responseStr  = HttpUtil.createPost(url)
                .body(jsonStr)
                .execute()
                .body();
        return JSONUtil.toBean(responseStr,ExecuteCodeResponse.class);
    }
}
